package com.yanqu.road.server.cmd.wineshop;

import com.yanqu.road.pb.wineshop.WineShopProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.wineshop.WineShopModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/7/20 16:43
 */
@Cmd(code = GameProtocol.S_WINESHOP_BEAUTY_PAY_EXIT, desc = "酒肆美女结算离开")
public class WineShopBeautyPayExitCmd extends AbstractCommand {
    private long id;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WineShopProto.WineShopBeautyPayExitReqMsg msg = WineShopProto.WineShopBeautyPayExitReqMsg.parseFrom(packet.getBytes());
        id = msg.getId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(WineShopModule.class).beautyPayAndExit(id);
    }

    @Override
    public void sendData(GamePlayer player) {
        WineShopProto.WineShopBeautyPayExitRespMsg.Builder respMsg = WineShopProto.WineShopBeautyPayExitRespMsg.newBuilder();
        respMsg.setRet(ret);
        player.sendPacket(ClientProtocol.U_WINESHOP_BEAUTY_PAY_EXIT, respMsg);
    }
}
